﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T17_常见类
{
    class Program 
    {
        static void Main(string[] args)
        {//数字类
            Console.WriteLine(Math.E);
            Console.WriteLine(Math.PI);
            Console.WriteLine(Math.Abs(-10));
            Console.WriteLine(Math.Floor(20.1));
            Console.WriteLine(Math.Round( 20.5));
            Console.WriteLine(Math.Sqrt(16));
            //stringbuilder类
            StringBuilder sb = new StringBuilder();
            Console.WriteLine(sb.Capacity);
            Console.WriteLine(sb.MaxCapacity);
            Console.WriteLine(sb.Length);
            string str = "是";
            sb.Append("我");
            sb.Append(str);
            sb.Append("中国人");
            Console.WriteLine(sb.ToString());
            //日期类
            Console.WriteLine(DateTime.Today);
            Console.WriteLine(DateTime.Parse("2018/10/30"));
            Console.WriteLine(DateTime.Now.AddDays(-1).ToShortDateString());
            Console.WriteLine(DateTime.Now.DayOfWeek);
            string[] day = new string[] { "星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" }; 
            Console.WriteLine(day[Convert.ToInt32(DateTime.Now.DayOfWeek)]);
            Console.WriteLine("请输入曰期"); 
                DateTime dt = DateTime.Parse(Console.ReadLine());
            string strWeek = "天一二三四五六".Substring(Convert.ToInt32(dt.DayOfWeek),1);
            Console.WriteLine("今天是{0}年{1}月{2}日星期{3},是一年中的第{4}天",
                dt.Year, dt.Month, dt.Day, strWeek, dt.DayOfYear);
            //非泛型集合
            ArrayList arrayList = new ArrayList();
            Console.WriteLine(arrayList.Capacity);
            arrayList.Add(1);
            arrayList.Add("字符串");
            printvalue(arrayList.GetType(), arrayList);
            //队列
            Queue queue = new Queue();
            queue.Enqueue(1);
            queue.Enqueue("asd");
            queue.Dequeue();
            printvalue(queue.GetType(),queue);
           
            //栈
            Stack stack = new Stack();
            stack.Push("fgh");
            stack.Push("jkl");
            stack.Pop();
            printvalue(stack.GetType(), stack);
            Console.ReadKey();
        }
        public static void printvalue(Type type,IEnumerable list)
        {
            StringBuilder sb = new StringBuilder();
            foreach (var item in list)
            {
                sb.Append(item);
            }
            Console.WriteLine(sb);
        }
    }
}
